#ifndef __LOG_H_
#define __LOG_H_

#include "stdint.h"
#include "stdio.h"

extern uint32_t g_log_level;

typedef enum _log_level log_level;
enum _log_level
{
    log_level_debug = 0,
    log_level_notice,
    log_level_err,
};

#define DEBUG(fmt, args... )    \
do{ \
    if(g_log_level <= log_level_debug)  \
    {   \
        printf(fmt, ##args);    \
    }   \
}while(0)

#define NOTICE(fmt, args... )    \
do{ \
    if(g_log_level <= log_level_notice)  \
    {   \
        printf(fmt, ##args);    \
    }   \
}while(0)

#define ERR(fmt, args... )    \
do{ \
    if(g_log_level <= log_level_err)  \
    {   \
        printf(fmt, ##args);    \
    }   \
}while(0)


#define DEBUG_FUNC_LINE(fmt, args... )    \
do{ \
    if(g_log_level <= log_level_debug)  \
    {   \
        printf("\n<%s(%d)>: "fmt, __FUNCTION__, __LINE__, ##args);    \
    }   \
}while(0)

#define NOTICE_FUNC_LINE(fmt, args... )    \
do{ \
    if(g_log_level <= log_level_notice)  \
    {   \
        printf("\n<%s(%d)>: "fmt, __FUNCTION__, __LINE__, ##args);    \
    }   \
}while(0)

#define ERR_FUNC_LINE(fmt, args... )    \
do{ \
    if(g_log_level <= log_level_err)  \
    {   \
        printf("\n<%s(%d)>: "fmt, __FUNCTION__, __LINE__, ##args);    \
    }   \
}while(0)

#define FUNC_BEGIN()    \
do{ \
    if(g_log_level <= log_level_debug)  \
    {   \
        printf("\n*******************%s begin!********************\n",  \
            __FUNCTION__);    \
    }   \
}while(0)

#define FUNC_FINISH()    \
do{ \
    if(g_log_level <= log_level_debug)  \
    {   \
        printf("*******************%s finish!*******************\n",    \
            __FUNCTION__);    \
    }   \
}while(0)

#endif